﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace App.Utility.Controllers
{
    public static class RuleViolations
    {
        public static void UpdateModelStateWithViolations(this Controller Controller,
            List<RuleViolation> RuleViolations)
        {

            foreach (var violation in RuleViolations)
            {
                Controller.ModelState.AddModelError(violation.PropertyName,
                    violation.ErrorMessage);
            }
        }
    }
}
